$(function () {
    $.ajax({
        async: true,
        dataType: "json",
        url: "/admin/toast/index",
        success: function (data) {
            if (data.status == 200) {
                if (data.data.enable == 1) {
                    toast(data.data.toast);
                }
            } else {
                toast("XCloud通知中心");
            }
        },
        error: function () {
            toast("XCloud通知中心");
        },
        type: "get"
    })
})
//大层
var slideBox = document.getElementById("slideBox");
//内容层
var slideContent = document.getElementById("slideContent");
//拼接层
var slideCopy = document.getElementById("slideCopy");
//循环相隔时间
var speed = 20;
//复制内容
slideCopy.innerHTML = slideContent.innerHTML;
console.log(slideBox.scrollLeft);

// *无缝切换函数，滚动值>=可视宽度，归0，否则数值递增
function seamlessSlide() {
    var seeWidth = slideContent.offsetWidth;
    // console.log(slideBox.scrollLeft)
    // console.log(seeWidth);
    if (slideBox.scrollLeft >= seeWidth) {
        slideBox.scrollLeft = 0;
    } else {
        slideBox.scrollLeft++;
    }
}

function toast(toast) {
    //每10毫秒循环执行slide
    $("#toast_content").html(toast);
    $("#toast_content2").html(toast);
    var runslide = setInterval(seamlessSlide, speed);
    //鼠标移到大层，循环终止
    /*slideBox.onmouseover = function () {
        clearInterval(runslide);
    }
    // //鼠标移开时，继续循环
    slideBox.onmouseleave = function () {
        setTimeout(function () {
            runslide = setInterval(seamlessSlide, speed);
        }, 300);
    }*/
}